" Vim settings file
" Maintainer:  Damien Gombault <desintegr@gmail.com>
" Last Change: 2008 Oct 28


""" General
language en_US.UTF-8
set nocompatible
filetype plugin indent on
set shortmess=filnxtToOI
set viminfo='20,\"500,h
set history=50


""" Interface
colorscheme delek
syntax on
set number
set numberwidth=1
set tabpagemax=20
set wildmode=longest,list
" Status info
set showcmd
set ruler
set laststatus=2
set statusline=%-3.3n\ %t\ %h%m%r%w\[%{strlen(&ft)?&ft:'none'},%{&encoding},%{&fileformat}]\ %=%-14.(%l,%c%V%)\ %<%P
" Scrolling
set scrolloff=3
set sidescrolloff=6
set scrolljump=3


""" Keyboard / Mouse
set backspace=indent,eol,start
set mouse=ar
set selection=inclusive
set virtualedit=block,onemore


""" Open / Save
set fileencodings=ucs-bom,utf-8,latin1
set nobackup
set noswapfile
set autowrite
autocmd BufRead * try | lcd %:p:h | catch | endtry


""" Editing
" Spelling
set spelllang=fr,en
set spellsuggest=best,10
" Indentation
set autoindent
set smartindent
" Tab
set expandtab
set smarttab
set shiftwidth=2
" Special chars
set listchars=eol:¬,nbsp:_,tab:▸\ ,trail:.
set showbreak=▸▸
" Search
set hlsearch
set incsearch
set ignorecase
set smartcase
" Folding
set foldmethod=syntax
set nofoldenable
" Completion
set completeopt=longest,menu,preview
" Split
set splitright
" Views / Sessions
set viewoptions=folds,cursor
autocmd BufWinEnter * try | loadview | catch | endtry
set sessionoptions=blank,buffers,curdir,folds,help,options,resize,tabpages,winsize
" Diff
set diffopt=filler,vertical
" Clipboard
set clipboard=autoselect
" Misc
set showmatch
set matchtime=15
set startofline
" Shell
set noshelltemp


""" Keyboard shortcuts
" Misc
map Y y$
map <S-Up> <Up>
map <S-Down> <Down>
imap <S-CR> <Esc>O
imap <C-BS> <C-w>
imap <C-Space> <Esc>a
" Tabs
map <A-Right> gt
map <A-Left> gT
" Save
nmap <C-S> <Esc>:w<CR>
imap <C-S> <Esc>:w<CR>
vmap <C-S> <Esc>:w<CR>
" Remplace
nmap <F2> :s/\<<C-R>=expand("<cword>")<CR>\>//<Left>
vmap <F2> ygv:<C-U>s/\<<C-R>"\>//<Left>
nmap <F3> :%s/\<<C-R>=expand("<cword>")<CR>\>//g<Left><Left>
vmap <F3> ygv:<C-U>%s/\<<C-R>"\>//g<Left><Left>
map <silent> <F5> :noh<CR>
" Spell
map <silent> <F6> :set spell!<CR>
" Wrap
map <silent> <F7> :set wrap!<CR>
" Make
map <silent> <F8> :make<CR>


""" Auto brackets
inoremap "" ""<Esc>i
inoremap ""; "";<Esc>hi
inoremap '' ''<Esc>i
inoremap ''; '';<Esc>hi

inoremap << <><Esc>i
inoremap </ </><Esc>i
inoremap <</ </><Esc>hi
inoremap <<! <!--  --><Esc>hhhi

inoremap (( ()<Left>
inoremap (<CR> (<CR>)<C-o>O
inoremap (; ();<Esc>hi
inoremap (<CR>; (<CR>);<C-o>O
inoremap ('; ('');<Esc>hhi
inoremap ("; ("");<Esc>hhi
inoremap (' ('')<Esc>hi
inoremap (" ("")<Esc>hi

inoremap {{ {}<Left>
inoremap {<CR> {<CR>}<C-o>O
inoremap {; {};<Esc>hi
inoremap {<CR>; {<CR>};<C-o>O
inoremap {'; {''};<Esc>hhi
inoremap {"; {""};<Esc>hhi
inoremap {' {''}<Esc>hi
inoremap {" {""}<Esc>hi
inoremap {{{ {{{ }}}<Esc>hhhi
inoremap {{{<CR> {{{ <CR>}}}<Esc>kA

inoremap [[ []<Left>
inoremap [<CR> [<CR>]<C-o>O
inoremap [; [];<Esc>hi
inoremap [<CR>; [<CR>];<C-o>O
inoremap ['; [''];<Esc>hhi
inoremap ["; [""];<Esc>hhi
inoremap [' ['']<Esc>hi
inoremap [" [""]<Esc>hi


""" User defined commands
command! Cd lcd %:p:h
command! Browse silent !xdg-open %:p:h


""" Misc
" TOhtml options
let html_ignore_folding=1
let html_use_css=1
let html_use_encoding="UTF-8"
let use_xhtml=1
" Netrw
let g:netrw_browse_split=0
let g:netrw_hide=1
let g:netrw_list_hide='^\.\w'
let g:netrw_liststyle=0
